#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int pivotIndex(int* nums, int numsSize)
{
    int sum = 0;
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        sum += nums[i];
    }
    int mid = 0;
    for (i = 0; i < numsSize; i++)
    {
        if (2 * mid + nums[i] == sum)
            return i;
        mid += nums[i];
    }
    return -1;
}